package com.yonyou.iuap.ipaas.connector.sdwcoatencent.internal.service.core.factory;

import cn.hutool.core.map.MapUtil;
import com.yonyou.iuap.ipaas.connector.sdwcoatencent.api.model.business.BaseBean;
import com.yonyou.iuap.ipaas.connector.sdwcoatencent.api.model.core.enums.ParamConvertServiceTypeEnum;
import com.yonyou.iuap.ipaas.connector.sdwcoatencent.internal.service.business.dept.convert.DeptParamConvertService;
import com.yonyou.iuap.ipaas.connector.sdwcoatencent.internal.service.business.msg.convert.NotifyParamConvertService;
import com.yonyou.iuap.ipaas.connector.sdwcoatencent.internal.service.business.msg.convert.ToDoParamConvertService;
import com.yonyou.iuap.ipaas.connector.sdwcoatencent.internal.service.business.msg.convert.WarningParamConvertService;
import com.yonyou.iuap.ipaas.connector.sdwcoatencent.internal.service.business.user.convert.UserParamConvertService;
import com.yonyou.iuap.ipaas.connector.sdwcoatencent.internal.service.core.ParamConvertService;

import java.util.Map;

public class ConvertFactory {

    private static final Map<String, ParamConvertService> SERVICE_CACHE = MapUtil.newConcurrentHashMap();

    private ConvertFactory() {
    }

    public static <T extends BaseBean> ParamConvertService getService(String ruleCode) {
        return (ParamConvertService)SERVICE_CACHE.get(ruleCode);
    }

    static {
        SERVICE_CACHE.put(ParamConvertServiceTypeEnum.BIPCONVERTUSER.getCode(), new UserParamConvertService());
        SERVICE_CACHE.put(ParamConvertServiceTypeEnum.BIPCONVERTDEPT.getCode(), new DeptParamConvertService());
        SERVICE_CACHE.put(ParamConvertServiceTypeEnum.BIPCONVERTODO.getCode(), new ToDoParamConvertService());
        SERVICE_CACHE.put(ParamConvertServiceTypeEnum.BIPCONVERNOTIFY.getCode(), new NotifyParamConvertService());
        SERVICE_CACHE.put(ParamConvertServiceTypeEnum.BIPCONVERTWARNING.getCode(), new WarningParamConvertService());
    }
}
